﻿
using System.Xml.Linq;

namespace SvGame.Objects;

[Desc("道具")]
public partial class Item
{
    #region 存档

    [Desc("UID")]
    public long Uid = 0;
    [Desc("ID")]
    public int ConfigId = 0;
    [Desc("Count")]
    public long Count = 0;

    #endregion

    #region 不存档 //[JsonIgnore]

    [Desc("环境")]
    [JsonIgnore]
    public object Env = null;
    public bool GetEnv(out object env)
    {
        env = Env;
        return (env != null);
    }
    public Room? GetRoom()
    {
        if (Env is Room)
        {
            return Env as Room;
        }
        return null;
    }
    [Desc("配置")]
    [JsonIgnore]
    public ConfigItemExt Cfg = null;

    #endregion

    // 名字
    [JsonIgnore]
    public string _Name = string.Empty;
    [JsonIgnore]
    public string Name
    {
        get
        {
            if (!_Name.IsNullOrEmpty()) 
            {
                return _Name;
            }
            return Cfg.SettBase.Name;
        }
        set
        {
            _Name = value;
        }
    }
    // 描述
    [JsonIgnore]
    public string _Desc = string.Empty;
    [JsonIgnore]
    public string Desc
    {
        get
        {
            if (!_Desc.IsNullOrEmpty())
            {
                return _Desc;
            }
            return Cfg.SettBase.Desc;
        }
        set
        {
            _Desc = value;
        }
    }

    public string DescShort() => $"{ChineseNumber(Count)}{Cfg.SettBase.Unit}{Name}";

    [JsonIgnore]
    public bool CanGet => Cfg.SettBase.CanGet;

    #region Tag

    public int Tag0 = 0;

    #endregion

}
